package com.yzpass.api.product;

import com.yzpass.api.common.Constant;
import com.yzpass.api.common.FilterDTO;
import com.yzpass.api.common.Result;
import com.yzpass.api.security.annotation.RequireEdit;
import com.yzpass.api.security.annotation.RequireFullControl;
import com.yzpass.api.security.annotation.RequireRead;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping(value = Constant.API + "product")
@RestController
public class ProductController {
    public final String resId = "product";
    @Resource
    ProductService productService;

    //@RequireFullControl(resId)
    @DeleteMapping("{id}")
    public Result delete(@PathVariable("id") String id) {
        return productService.delete(id);
    }

    //@RequireEdit(resId)
    @PostMapping("save")
    public Result<ProductDTO> save(@RequestBody ProductDTO input) {
        return productService.save(input);
    }

    //@RequireRead(resId)
    @GetMapping("{id}")
    public Result<ProductDTO> view(@PathVariable("id") String id) {
        return productService.view(id);
    }

    //@RequireRead(resId)
    @PostMapping("list")
    public Result<List<ProductDTO>> list(@RequestBody FilterDTO input) {
        return productService.list(input);
    }

}
